home *** CD-ROM | disk | FTP | other *** search
- Masterclass
-
-
- ARexx is the programming language which comes as part of the
- Amiga Operating System. It can be used as a stand-alone
- development system for writing utilites and small programs,
- or it can be used to control other applications.
-
- As it comes "out of the box", ARexx can appear quite a
- limiting language. Unless you make use of other
- applications, you are stuck with a Shell only text-based
- program: and this can look very dated and unimpressive.
-
- This month therefore, we'll take a look at some extras
- goodies which you can add to your system in order to make
- your ARexx programs considerably more powerful -- and user
- friendly. They won't cost you anything either, as they are
- either already present on your system or available for
- downloading from Aminet or a BBS, or if you must, you can
- order them from a public domain library.
-
- The goodies take the form of special "libraries". The
- library files themselves live in the LIBS: directory on your
- Workbench system. The libraries add commands which ARexx
- will recognise and execute, in exactly the same way as the
- standard "built in" commands. If ARexx is installed there
- already, you'll see two libraries called:
-
- rexxsyslib.library
- rexxsupport.library
-
- The first must be present for ARexx to work at all, as
- it contains the basic commands. The second is a library of
- extra commands. Most of these commands won't be needed, but
- you will occassionally need one or two of them, which is why
- they are worth mentioning.
-
- First of all though, we need to inform ARexx that the extra
- library exists and that we would appreciate it if it check
- it out when it found any new commands. There are two ways to
- go about this process.
-
- The first is to use the ARexx command "ADDLIB". ADDLIB works
- from within the ARexx script itself. To load the RexxSupport
- library, include ADDLIB as in this short program:
-
- ---------------
-
- /* ADDLIB example */
-
- ADDLIB("rexxsupport.library",0,-30,0)
-
- delay(10*50)
-
- ----------------
-
-
- (rex1.iff, Use a text editor such as Ed, GoldEd or CygusEd
- to enter the ARexx scripts.)
-
- If you didn't link in the new library (for example, if you
- spelt the library name incorrectly, or simply left that line
- out), you'll have seen an error such as "Command returned
- 10/15: Function not found".
-
- If you got it right, the script will use DELAY to go into a
- pause for ten seconds, and then finished. See the box out
- for more details of the other new Rexx Support commands.
-
- The second way to incorporate the library commands is to use
- the "rxlib" command directly from the Shell, before you run
- the ARexx script. Here is the command you would enter at the
- Shell if you wanted to make use of any of the functions
- which are present in the rexxsupport libary.
-
- rxlib rexxsupport.library 0 -30 0
-
- The numbers which follow the name of the library are for
- setting priorities and checking version numbers: there is
- nothing to be gained by altering them.
-
- Once you enter this line, the new commands become part of
- ARexx. So, for example, you could enter the following script
- and execute it:
-
- ---------------
-
- /* Wait for ten seconds */
-
- DELAY(10*50)
-
- ---------------
-
-
- If you find yourself using the new library commands a lot,
- it might be worthwhile adding the rxlib line to your
- user-startup sequence. If you are in the habit of sharing
- scripts, remember though that other users might not have the
- libraries pre-loaded in this way.
-
-
-
- DIY Graphical User Interface
-
- As you'll have seen, one of the drawbacks of the standard
- ARexx system is that it is text only. It looks dated and
- dull and at times is a pig to use. Who wants to have to
- enter numbers and filenames from the Shell?
-
- To see how we can expand ARexx to make use of the standard
- Amiga Intuition system, you'll need to get hold of an
- archive with the catchy name of "RexxArpLib3_0.lzx". I found
- it on Disk A of "Aminet set 2" in the "util/rexx" directory.
-
- As you might expect, "RexxArpLib" is another support
- library, although this one adds commands which can control
- Intuition. To use it, you will need to extract the files and
- copy the libraries to the LIBS: drawer on your system. Now,
- using one of the two techniques for including the library,
- you can you write some ARexx programs to impress your
- friends and family (although, let's face it, few will
- actually be impressed because they won't have a clue what
- you are talking about).
-
- Here's a small program which uses RexxArpLib to open some
- requestors.
-
-
- ---------------
-
- /* The REAL Rod Hull tester */
-
- ADDLIB("rexxarplib.library",0,-30,0)
-
-
- answer= request(25,25," Do like Green Jelly? ",,"Yes","No")
-
- if answer='OKAY' then
- request(80,40,"Good for you!",,"I LOVE it!")
- else
- request(80,40,"You are an imposter!",,"Sorry")
-
-
- ---------------
-
- (rex2.iff)
-
-
- If you look through the copious documentation supplied with
- RexxArpLib you'll see that there are dozens of new commands.
- These can be used to open Windows, call standard
- FileRequestors set up gadgets. Your Arexx Scripts need never
- be dull again!
-
- (rex3.iff, The RexxArp library includes routines to open
- requestors for almost everything -- including Fonts and
- files.)
-
-
-
-
- Box out: Some of the new funtions in RexxSupport Library
-
-
- DELAY(n)
-
- Pause the program for n ticks -- a tick is 1/50th of a
- second on PAL Amigas.
-
- Example: Delay(500) /* Wait 10 seconds */
-
- FORBID(), PERMIT()
-
- These commands suspend and reactivate multitasking. You
- should only really need to use these when you are performing
- some kind of low-level memory access and it is imperitive no
- other program can interfere.
-
- Example:
-
- /* Forbit/Permit */
-
- ADDLIB("rexxsupport.library",0,-30,0)
-
- DELAY(100)
- FORBID()
- SAY "I have control now."
- DO 50000; END
- SAY "Back to you, master"
- PERMIT()
- DELAY(100)
-
- /* end */
-
-
- DELETE(filename)
-
- Erase an AmigaDOS file. Wildcards are not allowed.
- Returns 0 if deleting the file is not possible.
-
- example:
-
- /* Delete me ! */
-
- ADDLIB("rexxsupport.library",0,-30,0)
-
- plop=delete("ram:test.dat")
-
- if plop=0 then
- say "Sorry, couldn't delete that file."
-
- /* end */
-
-
-
- MAKEDIR(directory name)
-
- Create an AmigaDOS Directory.
-
- Example:
-
- MAKEDIR("ram:plop")
-
- RENAME (oldname, newname)
-
- Rename a file or directory
-
- Example:
- RENAME ("old.dat","old.bak")
-
-
-
-
-
- Hot tip
-
- Sometimes you may need to perform a quick calculation whilst
- you are seated at your Amiga, and frankly you couldn't be
- bothered trying to find a pocket calculator or even run a
- calculator program. Here's how ARexx can be used.
-
- All you have to do is pen a Shell, and enter something like:
-
- rx "say 173*34"
-
- or
-
- rx "say 182/11"
-
-
- (rex4.iff, Use ARexx from the Shell to save you fumbling for a calculator)
-
-
-
- --
-
- John Kennedy
-
-
-
-